package com.tencent.compose.sample.mainpage.material3

import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import org.jetbrains.compose.ui.tooling.preview.Preview


@Composable
@Preview()
internal fun ButtonDemo(){
    var isFavorite by remember { mutableStateOf(false) }
    Button(
        onClick = { isFavorite = !isFavorite },
        contentPadding = ButtonDefaults.ButtonWithIconContentPadding,
    ) {
        Icon(
            Icons.Filled.Favorite,
            contentDescription = if (isFavorite) "取消收藏" else "添加收藏",
            tint = if (isFavorite) Color.Red else Color.White
        )
        Spacer(Modifier.size(ButtonDefaults.IconSpacing))
        Text("Like")
    }
}